
import logging

import requests

class Test():
    token = ""
    def setup_method(self):
        print("执行前用例")
    def teardwon_method(self):
        print("执行后用例")
    #登录--正例
    def test_denglu(self):
        url= "http://10.59.9.21/api/user/login"
        doby={"username":"admin","password":"8i4De25KlVQVwqTDgTNGqw=="}
        heds={"content-type":"application/json"}
        r = requests.post(url=url,json=doby,headers=heds)
        print("登录",r.json())
        Test.token = r.json()['token']
        assert r.status_code == 200
    #cese1: 新增地区添加山东 曹县1，添加成功
    def test_tianjia2(self):
        try:
            url="http://10.59.9.21/api/area/add"
            doby={"atype":2,"name":"山东 曹县595","sort":"1022"}
            heds={"uid":"1","token":Test.token}
            r = requests.post(url=url,json=doby,headers=heds)
            print("新增地区1",r.json())
            assert r.status_code == 200
            assert "添加成功" in r.json()
        except Exception as e:
            logging.info(e)

        # cese1: 搜索山东 曹县1，添加成功
    def test_tianjia3(self):
        try:
            url = "http://10.59.9.21/api/area/get"
            body= {"wheres":"pk_id like \"%%\" and name like \"%山东曹县565%\" ","sorts":"atype asc,sort asc","pageIndex":1,"pageSize":10}
            heds = {"uid": "1", "token": Test.token}
            r = requests.post(url=url, json=body, headers=heds)
            print("新增地区1", r.json())
            assert r.status_code == 200
        except Exception as e:
            logging.info(e)
